package com.lc.communication.controller;

import com.lc.communication.service.NettyService;
import com.lc.communication.vo.RequestVo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.concurrent.Callable;

/**
 * @author liuhf17
 * @version 1.0.0
 * @ClassName TestController.java
 * @Description TODO
 * @createTime 2024年06月11日 16:13:00
 */
@RestController
public class NettyController {

    @Resource
    private NettyService nettyService;

    @GetMapping("/netty/test/{d}")
    public String test(@PathVariable("d") String d) {
        return "请求成功：d=" + d;
    }

    @PostMapping("/netty/access")
    public Callable<Object> access(@RequestBody RequestVo vo) {
        return () -> nettyService.doSomethingAsync(vo).get();
    }

}
